SET(ENV{PATH} "${PATH}${SEPARATOR}$ENV{PATH}")

set(XDMF_DSM_IS_CRAY "@XDMF_DSM_IS_CRAY@")
if (XDMF_DSM_IS_CRAY)
  SET(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}${SEPARATOR}${LDPATH}")
else (XDMF_DSM_IS_CRAY)
  SET(ENV{LD_LIBRARY_PATH} "${LDPATH}${SEPARATOR}$ENV{LD_LIBRARY_PATH}")
endif (XDMF_DSM_IS_CRAY)

SET(ENV{MPIEXEC} "@MPIEXEC@")

MESSAGE("| Calling:\t${EXECUTABLE} ${ARGUMENTS}")
EXECUTE_PROCESS(
       COMMAND ${EXECUTABLE} ${ARGUMENTS} 
			RESULT_VARIABLE cxx_result
            OUTPUT_VARIABLE cxx_output
            ERROR_VARIABLE  cxx_error
)

MESSAGE("| Call Result:\t${cxx_result}")
MESSAGE("| Call Output: Begin\n${cxx_output}")
MESSAGE("| Call Output: End")
IF(cxx_error)
	MESSAGE("| Call Error: Begin\n${cxx_error}")
	MESSAGE("| Call Error: End")
ENDIF()
MESSAGE("| Call Ended")
MESSAGE("----------------------------------------------------------")

# Let's make sure that if the test failed, it failed with CTest too
IF(cxx_error)
	MESSAGE(SEND_ERROR "Test Failed.")
ENDIF()

IF(NOT ${cxx_result} EQUAL "0")
	MESSAGE(SEND_ERROR "Test Failed.")
ENDIF()
